<?php
$c = new SaeCounter();
$Queuing = $c->get('Queuing');
$mysql = new SaeMysql();
$sql = "SELECT COUNT(*) FROM Queuing";
$data = $mysql->getData($sql);
$sum = $data[0]['COUNT(*)'];
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="./img/weixin.ico">

    <title>微信商家预约互动系统</title>

    <!-- Bootstrap core CSS -->
    <link href="./css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="./css/dashboard.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="./js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
    body{
      font-family: 微软雅黑;
      font-size: 16px;
    }
    .sidebar {
        padding-top: 20px;
        font-size: 18px;
     }
    .now-number{
      background-color: #5bb793;
      height: 350px;
      width: 350px;
      margin: 0 auto;
      border-radius: 50%;
      line-height:350px;
      color: #fff;
    }
    .sum-number{
      background-color: #754DC5;
      height: 280px;
      width: 280px;
      margin: 0 auto;
      border-radius: 50%;
      line-height:280px;
      color: #fff;
    }
    #footer{
      margin-top: 150px;
    }
    #footer button{
      margin-right: 20px;
    }
    </style>
  </head>

  <body>

    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">微信商家预约互动系统</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
            <li><a href="#">登陆</a></li>
            <li><a href="#">退出</a></li>
          </ul>
        </div>
      </div>
    </nav>

    <div class="container-fluid">
      <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
          <ul class="nav nav-sidebar">
            <!-- <li class="active"><a href="#">Overview</a></li> -->
            <li><a href="http://mewechat.sinaapp.com/wcpd/QueuingHome.php">微信排队叫号</a></li>
            <li><a href="#">微信投票(开发中)</a></li>
            <li><a href="http://mewechat.sinaapp.com/wxscj/counter.html">微信抽奖</a></li>
          </ul>
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
          <h1 class="page-header"></h1>

          <div class="row placeholders">
            <div class="col-xs-6 col-sm-12 placeholder">
              <!-- <img data-src="holder.js/200x200/auto/sky" class="img-responsive" alt="Generic placeholder thumbnail"> -->
              <div class="now-number"><div style="font-size:50px">当前<span id="now" style="font-size:80px"><?php echo $Queuing; ?></span>号</div></div>
            </div>
            <!-- <div class="col-xs-6 col-sm-6 placeholder">
              <div class="sum-number"><div style="font-size:50px">总共<span style="font-size:80px"><?php echo $sum; ?></span>号</div></div>
            </div> -->        
          </div>
          <div id="footer">
             <button class="btn btn-lg btn-danger pull-right" id="reset">重置</button>
             <button class="btn btn-lg btn-success pull-right" id="next">下一位</button>
          </div> 
        </div>
      </div>
    </div>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    	$("#reset").click(function(){
    		$.ajax({
    			type: "POST",
    			url: "QueuingReset.php",
    			success: function(data){
    				$("#now").text(0);
    				alert("数据已重置");
    			}
    		})
    	})

    	$("#next").click(function(){
    		$.ajax({
    			type: "POST",
    			url: "QueuingServer.php",
    			success: function(data){
    				$("#now").text(data);
    				alert("通知已发送");
    			}
    		})
    	})
    })
    </script>
    <script src="./js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="./js/ie10-viewport-bug-workaround.js"></script>
    <script type="text/javascript">

    </script>
  </body>
</html>
